<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test02</title>
    <script src="https://unpkg.com/vue/dist/vue.js" type="text/javascript"></script>
</head>
<body>

<div id="app">
    <p>{{ sum }}</p>
    <p>{{ csum }}</p>
</div>

<script>
    let vm = new Vue({
        el: '#app',
        data: {
            a: 0,
            b: 0,
            sum: 0,
        },
        watch: {
            a: function (val) {
                this.sum = val + this.b;
            },
            b: function (val) {
                this.sum = this.a + val;
            }
        },
        computed: {
            csum: function () {
                return this.a + this.b;
            }
        }
    });

    vm.a = 10;
    vm.b = 8;

</script>

</body>
</html>